let now = Date.now();
async function fetch(url) {
  return timeout(1000, url);
}

const timeout = (time, url) =>
  new Promise((resolve) => {
    setTimeout(() => {
      console.log(Date.now() + "   " + url);
      resolve();
    }, time);
  });

function wrapper(fetch) {
  const list = [];
  let panding = false;
  return async function (url) {
    if (panding) {
      await new Promise((resolve) => {
        list.push(resolve);
      });
    }

    panding = true;
    let result = await fetch(url);
    panding = false;
    if (list.length) list.shift()();
    return result;
  };
}

const func = wrapper(fetch);
func("a");
func("b");
func("c");
